package com.djq.project.mq.producer.routing;

import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 路由模式
 */
@RestController
public class SendRouting {
    public final static String  DIRECT_EXCHANGE="routing_exchange";
    @Autowired
    private RabbitTemplate template;

    @RequestMapping("/sendRouting")
    @Scheduled(fixedDelay  =1000, initialDelay = 500)
    public void sendRouting(String routingKey,String message) {
        template.convertAndSend(DIRECT_EXCHANGE, routingKey, message);
    }
}
